package main

import (
	"fmt"
	"github.com/micro/go-micro/v2"
	log "github.com/micro/go-micro/v2/logger"
	"github.com/micro/go-micro/v2/registry"
	"go-gin-api/app/config"
	"go-gin-api/app/grpcserver/grpcservertag"
	"go-gin-api/app/model/tag"
	grpctag "go-gin-api/app/proto/tag"
)

func main() {
	// 使用etcd注册
	//micReg := etcd.NewRegistry(registryOptions)
	// 新建服务
	service := micro.NewService(
		micro.Name("tag"),
		//micro.Registry(micReg),
		micro.Version("latest"),
	)
	// 服务初始化
	service.Init()
	// 注册服务
	NewMysqlTag := tag.NewMysqlTag()
	_= grpctag.RegisterTagHandler(service.Server(), grpcservertag.NewTagSever(NewMysqlTag))
	// 启动服务
	if err := service.Run(); err != nil {
		log.Fatal(err)
	}
}
// 注册etcd
func registryOptions(ops *registry.Options) {
	ops.Addrs = []string{fmt.Sprintf("%s:%d", config.EtcdHostTag, config.EtcdPortTag)}
}
